<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<style>
    .queueList {
        height: 270px;
    }

    .form-group {
        width: 700px;
        text-align: center;
    }
</style>
<link th:href="@{/css/plugins/webuploader/webuploader.css}" rel="stylesheet"/>
<link th:href="@{/css/demo/webuploader-demo.css}" rel="stylesheet"/>
<link th:href="@{/ajax/libs/iCheck/custom.css}" rel="stylesheet"/>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-products-edit" th:object="${products}">
        <input id="id" name="id" th:field="*{id}" type="hidden">
        <div class="form-group">
            <div class="form-group">
                <label class="col-sm-3 control-label"><span class="must_be_color">*</span>category：</label>
                <div class="col-sm-9">
                    <select class="form-control" id="productClass" name="productClass"
                            th:with="type=${@dict.getType('erp_product_class')}">
                        <option th:each="dict : ${type}" th:text="${dict['dictLabel']}"
                                th:value="${dict['dictValue']}" th:field="*{productClass}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label"><span class="must_be_color">*</span>type：</label>
                <div class="col-sm-9">
                    <select class="form-control" id="productType" name="productType"
                            th:with="type=${@dict.getType('erp_product_type')}">
                        <option th:each="dict : ${type}" th:text="${dict['dictLabel']}"
                                th:value="${dict['dictValue']}" th:field="*{productType}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label"><span class="must_be_color">*</span>mainSKU：</label>
                <div class="col-sm-9">
                    <input type="text" name="mainSKU" class="form-control" th:field="*{mainSKU}" autocomplete="off">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">relevanceSKU：</label>
                <div class="col-sm-9">
                    <input type="text" name="unionSKU" th:field="*{unionSKU}" class="form-control" autocomplete="off">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label"><span class="must_be_color">*</span>productName：</label>
                <div class="col-sm-9">
                    <input type="text" name="productName" th:field="*{productName}" class="form-control"
                           autocomplete="off">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label"><span class="must_be_color">*</span>SIZE：</label>
                <div class="col-sm-9">
                    <input type="text" name="size" th:field="*{size}" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">EAN：</label>
                <div class="col-sm-9">
                    <input type="text" name="eAN" th:field="*{eAN}" class="form-control" autocomplete="off">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">remark：</label>
                <div class="col-sm-9">
                    <input type="text" name="bz" th:field="*{bz}" class="form-control" autocomplete="off">
                </div>
            </div>
            <div id="uploader" class="wu-example">
                <div class="queueList">
                    <div id="dndArea" class="placeholder">
                        <div id="filePicker"></div>
                    </div>
                </div>
                <div class="statusBar" style="display:none;">
                    <div class="progress">
                        <span class="text">0%</span>
                        <span class="percentage"></span>
                    </div>
                    <div class="info"></div>
                    <div class="btns">
                        <div id="filePicker2"></div>
                        <div class="uploadBtn">upload</div>
                    </div>
                </div>
            </div>
        </div>


        <!--
                    <div class="form-group">
                        <label class="col-sm-3 control-label">创建人编号：</label>
                        <div class="col-sm-8">
                            <input id="creatorId" name="creatorId" th:field="*{creatorId}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">创建日期：</label>
                        <div class="col-sm-8">
                            <input id="createDate" name="createDate" th:field="*{createDate}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">修改人编号：</label>
                        <div class="col-sm-8">
                            <input id="updateId" name="updateId" th:field="*{updateId}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">修改日期：</label>
                        <div class="col-sm-8">
                            <input id="updateDate" name="updateDate" th:field="*{updateDate}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">公司id：</label>
                        <div class="col-sm-8">
                            <input id="companyId" name="companyId" th:field="*{companyId}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">商品名称：</label>
                        <div class="col-sm-8">
                            <input id="productName" name="productName" th:field="*{productName}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">商品类别：</label>
                        <div class="col-sm-8">
                            <input id="productClass" name="productClass" th:field="*{productClass}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">商品类型：</label>
                        <div class="col-sm-8">
                            <input id="productType" name="productType" th:field="*{productType}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">主SKU：</label>
                        <div class="col-sm-8">
                            <input id="mainSKU" name="mainSKU" th:field="*{mainSKU}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">unionSKU：</label>
                        <div class="col-sm-8">
                            <input id="unionSKU" name="unionSKU" th:field="*{unionSKU}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">size：</label>
                        <div class="col-sm-8">
                            <input id="size" name="size" th:field="*{size}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">EAN：</label>
                        <div class="col-sm-8">
                            <input id="eAN" name="eAN" th:field="*{eAN}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">图片地址：</label>
                        <div class="col-sm-8">
                            <input id="picUrl" name="picUrl" th:field="*{picUrl}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">采购数量：</label>
                        <div class="col-sm-8">
                            <input id="purchaseQuantity" name="purchaseQuantity" th:field="*{purchaseQuantity}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">确认数量：</label>
                        <div class="col-sm-8">
                            <input id="submitQuantity" name="submitQuantity" th:field="*{submitQuantity}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">售出数量：</label>
                        <div class="col-sm-8">
                            <input id="soldQuantity" name="soldQuantity" th:field="*{soldQuantity}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">退货数量：</label>
                        <div class="col-sm-8">
                            <input id="refundQuantity" name="refundQuantity" th:field="*{refundQuantity}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">退货入库量：</label>
                        <div class="col-sm-8">
                            <input id="refundPutInQuantity" name="refundPutInQuantity" th:field="*{refundPutInQuantity}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">退货损耗量：</label>
                        <div class="col-sm-8">
                            <input id="refundLossQuantity" name="refundLossQuantity" th:field="*{refundLossQuantity}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">FBS转入：</label>
                        <div class="col-sm-8">
                            <input id="fbsIntoQuantity" name="fbsIntoQuantity" th:field="*{fbsIntoQuantity}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">FBS退回入库量：</label>
                        <div class="col-sm-8">
                            <input id="fbsRefundPutInQuantity" name="fbsRefundPutInQuantity" th:field="*{fbsRefundPutInQuantity}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">FBS退回损耗量：</label>
                        <div class="col-sm-8">
                            <input id="fbsRefundLossQuantity" name="fbsRefundLossQuantity" th:field="*{fbsRefundLossQuantity}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">国内仓损耗量：</label>
                        <div class="col-sm-8">
                            <input id="chinaStorageLossQuantity" name="chinaStorageLossQuantity" th:field="*{chinaStorageLossQuantity}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">海外仓损耗量：</label>
                        <div class="col-sm-8">
                            <input id="overseasStorageLossQuantity" name="overseasStorageLossQuantity" th:field="*{overseasStorageLossQuantity}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">分享量：</label>
                        <div class="col-sm-8">
                            <input id="shareQuantity" name="shareQuantity" th:field="*{shareQuantity}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">：</label>
                        <div class="col-sm-8">
                            <input id="sharePrice" name="sharePrice" th:field="*{sharePrice}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">：</label>
                        <div class="col-sm-8">
                            <input id="bz" name="bz" th:field="*{bz}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">：</label>
                        <div class="col-sm-8">
                            <input id="field1" name="field1" th:field="*{field1}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">：</label>
                        <div class="col-sm-8">
                            <input id="field2" name="field2" th:field="*{field2}" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">：</label>
                        <div class="col-sm-8">
                            <input id="field3" name="field3" th:field="*{field3}" class="form-control" type="text">
                        </div>
                    </div>-->
        <div class="form-group">
            <div class="form-control-static col-sm-offset-9">
                <button type="submit" class="btn btn-primary">submit</button>
                <button onclick="$.modal.close()" class="btn btn-danger" type="button">close</button>
            </div>
        </div>
    </form>
</div>
<div th:include="include::footer"></div>
<div th:include="include::footer"></div>
<script th:src="@{/js/plugins/webuploader/webuploader.min.js}"></script>
<script th:src="@{/js/demo/webuploader-demo.js}"></script>
<!--<script th:src="@{/ajax/libs/select/select2.js}"></script>-->
<script type="text/javascript">

    var imgurl = '';

    $("#form-products-edit").validate({
        rules: {
            mainSKU: {
                required: true,
            },
            productName: {
                required: true,
            },
            size: {
                required: true,
            }
        },
        submitHandler: function (form) {
            edit();
        }
    });

    function edit () {
        var id = $("input[name='id']").val();
        var productClass = $("#productClass option:selected").val();
        var productType = $("#productType option:selected").val();
        var mainSKU = $("input[name='mainSKU']").val();
        var unionSKU = $("input[name='unionSKU']").val();
        var productName = $("input[name='productName']").val();
        var size = $("input[name='size']").val();
        var eAN = $("input[name='eAN']").val();
        var bz = $("input[name='bz']").val();
        var picUrl = imgurl === '' ? '' : JSON.parse(imgurl).msg;
        $.ajax({
            cache: true,
            type: "POST",
            url: ctx + "module/products/edit",
            data: {
                "id": id,
                "productClass": productClass,
                "productType": productType,
                "mainSKU": mainSKU,
                "unionSKU": unionSKU,
                "productName": productName,
                "size": size,
                "eAN": eAN,
                "bz": bz,
                "picUrl": picUrl,
            },
            async: false,
            error: function (request) {
                $.modal.alertError("system error");
            },
            success: function (data) {
                $.operate.saveSuccess(data);
            }
        });
    }

</script>

</body>
</html>
